package com.wulinbus.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.wulinbus.dao.user.UserCashLogDAO;
import com.wulinbus.model.UserCashLogModel;
import com.wulinbus.service.UserCashLogService;
import com.wulinbus.service.UserService;

@Service
public class UserCashLogServiceImpl implements UserCashLogService{
	
	@Resource
	UserCashLogDAO userCashLogDAO;
	
	@Resource
	UserService userService;
	
	public UserCashLogModel getById(Integer lid){
		return userCashLogDAO.getById(lid);
	}

	public List<UserCashLogModel> getList(Integer start, Integer count){
		return userCashLogDAO.getList(start, count);
	}
	
	public Integer getListCount(){
		return userCashLogDAO.getListCount();
	}
	
	public List<UserCashLogModel> getListByUid(Integer uid,Integer start, Integer count){
		return userCashLogDAO.getListByUid(uid, start, count);
	}
	
	public Integer getListCountByUid(Integer uid){
		return userCashLogDAO.getListCountByUid(uid);
	}
	
	public Integer cashHandle(UserCashLogModel cashlog){
		userService.addBalance(cashlog.getUid(), -cashlog.getMoney());
		return userCashLogDAO.insert(cashlog);
	}

	public Integer updateState(Integer lid,Integer uid){
		return userCashLogDAO.updateState(lid,uid);
	}

	public Integer delete(Integer lid,Integer uid){
		return userCashLogDAO.delete(lid,uid);
	}
}
